﻿using NeuralLib;

namespace NEATlib
{
    public static class GenomesCreator
    {
        public static Genom GetInitialGenom(NeuralNetworkInfo info)
        {
            var neuronId = 0;
            var connectionHistoryId = 1;
            var genom = new Genom();
            for (var i = 0; i < info.InputCount; i++)
            {
                genom.Neurons.Add(new NeuronGene(neuronId, ENeuronType.NtInput,1));
                neuronId++;
            }

            for (var i = 0; i < info.OutputLayerNeuronCount; i++)
            {
                genom.Neurons.Add(new NeuronGene(neuronId, ENeuronType.NtOutput,-1));
                for (var j = 0; j < info.InputCount; j++)
                {
                    genom.Connections.Add(new ConnectionGene(genom.Neurons[j].NeuronIndex, neuronId,
                       (Roulette.Double()-Roulette.Double())/2, connectionHistoryId));
                    connectionHistoryId++;
                }
                neuronId++;
            }
            return genom;
        }
    }
}
